package de.hub.sar.itsec.sslfetcher;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class LoaderThreadPoolExecuter extends ThreadPoolExecutor {
	public LoaderThreadPoolExecuter(int maximumPoolSize, 
			ThreadFactory threadFactory) {
		super(maximumPoolSize, maximumPoolSize, 1000L, TimeUnit.MILLISECONDS, 
				new LinkedBlockingQueue<Runnable>(), threadFactory);
	}

	@Override
	protected void beforeExecute(Thread t, Runnable r) {
		LoaderThread thread;
		LoadRunner runnable;
		
		thread = (LoaderThread) t;
		runnable = (LoadRunner) r;
		
		runnable.setFetcher(thread.getFetcher());
		runnable.setSaver(thread.getSaver());
	}
}
